import { BottomTabBarButtonProps } from "@react-navigation/bottom-tabs";
import { TouchableOpacity, Pressable } from "react-native";
import * as Haptics from "expo-haptics";
import { Platform } from "react-native";

export function HapticTab(props: BottomTabBarButtonProps) {
  const handlePress = (ev: any) => {
    // 在 iOS 上添加触觉反馈
    if (Platform.OS === "ios") {
      Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
    }

    // 这里可以添加自定义的跳转逻辑
    if (props.onPress) {
      props.onPress(ev);
    }
  };

  return (
    <TouchableOpacity {...props} onPress={handlePress}>
      {props.children}
    </TouchableOpacity>
  );
}
